<?php
	if (file_exists("../_libs/mysql.php")) {
		chmod("../_libs/mysql.php", 0777);
		include('../_libs/mysql.php');
		$sql = "
CREATE TABLE `log_action` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `userID` int(11) NOT NULL,
  `message` text NOT NULL,
  `timestamp` datetime NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

CREATE TABLE `log_lastsearch` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `text` varchar(255) NOT NULL,
  `timestamp` datetime NOT NULL,
  `userID` int(11) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

CREATE TABLE `module_banlist` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `userID` int(11) NOT NULL,
  `reason` text NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

CREATE TABLE `module_calendar` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `start` datetime NOT NULL,
  `end` datetime NOT NULL,
  `userID` int(11) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

CREATE TABLE `module_creport` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `userID` int(11) NOT NULL,
  `reason` text NOT NULL,
  `timestamp` datetime NOT NULL,
  `stars` int(11) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

CREATE TABLE `module_donate` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `userID` int(11) NOT NULL,
  `amount` int(11) NOT NULL,
  `timestamp` datetime NOT NULL,
  `reason` text NOT NULL,
  `admin` int(11) NOT NULL,
  `coins` int(11) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

CREATE TABLE `module_events` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `title` varchar(255) NOT NULL,
  `beginn` date NOT NULL,
  `end` date NOT NULL,
  `story` text NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

CREATE TABLE `module_news` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `userID` int(11) NOT NULL,
  `title` text NOT NULL,
  `message` text NOT NULL,
  `timestamp` datetime NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

CREATE TABLE `module_preport` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `userID` int(11) NOT NULL,
  `reportID` int(11) NOT NULL,
  `timestamp` datetime NOT NULL,
  `title` varchar(255) NOT NULL,
  `reason` text NOT NULL,
  `status` int(11) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

CREATE TABLE `module_preport_answers` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `reportID` int(11) NOT NULL,
  `adminID` int(11) NOT NULL,
  `title` varchar(255) NOT NULL,
  `message` text NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

CREATE TABLE `module_rules` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(255) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

CREATE TABLE `module_rules_points` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `ruleID` int(11) NOT NULL,
  `text` text NOT NULL,
  `title` varchar(255) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

CREATE TABLE `module_shoutbox` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `userID` int(11) NOT NULL,
  `message` text NOT NULL,
  `timestamp` datetime NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

CREATE TABLE `module_votebanners` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `img` varchar(255) NOT NULL,
  `link` varchar(255) NOT NULL,
  `coins` int(11) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

CREATE TABLE `website_access_levels` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `title` varchar(255) NOT NULL,
  `access_level` int(11) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

INSERT INTO website_access_levels VALUES ('1','Rookie','1');
INSERT INTO website_access_levels VALUES ('2','better Rookie','2');
INSERT INTO website_access_levels VALUES ('3','Gamemaster','3');
INSERT INTO website_access_levels VALUES ('4','Super Gamemaster','4');
INSERT INTO website_access_levels VALUES ('5','Administrator','5');

CREATE TABLE `website_languages` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `lang` varchar(255) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

INSERT INTO website_languages VALUES ('1','de');
INSERT INTO website_languages VALUES ('2','en');

CREATE TABLE `website_modules` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `title` varchar(255) NOT NULL,
  `access_level` int(11) NOT NULL,
  `licencekey` text NOT NULL,
  `module` varchar(255) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

INSERT INTO website_modules VALUES ('1','Dashboard','1','','home');
INSERT INTO website_modules VALUES ('2','News','1','','news');
INSERT INTO website_modules VALUES ('3','Edit Profile','1','','myprofile');
INSERT INTO website_modules VALUES ('4','Banlist','2','','banlist');
INSERT INTO website_modules VALUES ('5','Events','2','','events');
INSERT INTO website_modules VALUES ('6','Rules','2','','rules');
INSERT INTO website_modules VALUES ('7','Search Users','2','','search');
INSERT INTO website_modules VALUES ('8','Show Petitions','2','','petitions');
INSERT INTO website_modules VALUES ('9','Supportcalendar','2','','calendar');
INSERT INTO website_modules VALUES ('11','Shop Management','5','','shop');
INSERT INTO website_modules VALUES ('12','Donate System','5','','donate');
INSERT INTO website_modules VALUES ('13','Criminal Report System','5','','creport');
INSERT INTO website_modules VALUES ('14','Player Report','5','','report');
INSERT INTO website_modules VALUES ('15','Votebanners','5','','votebanners');
INSERT INTO website_modules VALUES ('16','Most buyed Items','5','','buyeditems');
INSERT INTO website_modules VALUES ('19','Change Accountname','5','','rename');
INSERT INTO website_modules VALUES ('21','Options','5','','options');
INSERT INTO website_modules VALUES ('22','Profile','1','','profile');
INSERT INTO website_modules VALUES ('23','Character','1','','character');
INSERT INTO website_modules VALUES ('24','Listview','2','','lists');
INSERT INTO website_modules VALUES ('25','Announcements','5','','announcements');
INSERT INTO website_modules VALUES ('26','Query Builder','5','','querybuilder');
INSERT INTO website_modules VALUES ('999','Logout','5','','logout');

CREATE TABLE `website_navigation` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `title` varchar(255) NOT NULL,
  `access_level` int(11) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

INSERT INTO website_navigation VALUES ('2','Support','2');
INSERT INTO website_navigation VALUES ('3','Administration','5');
INSERT INTO website_navigation VALUES ('6','Main','1');

CREATE TABLE `website_settings` (
  `ip_server` text NOT NULL,
  `gameserver_port` int(11) NOT NULL,
  `loginserver_port` int(11) NOT NULL,
  `ip_teamspeak` text NOT NULL,
  `teamspeak_port` int(11) NOT NULL,
  `title` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

INSERT INTO website_settings VALUES ('127.0.0.1','80','80','127.0.0.1','80','HybridCMS - Rapid Aion System');








";
		$connection->exec($sql);
		echo '<meta http-equiv="refresh" content="8; URL=?i=step5">';
	} else {
		echo '<meta http-equiv="refresh" content="8; URL=?i=step1">';
	}
?>
 <script type="text/javascript">
$(document).ready(function() {
	$("#typewriter").typewriter();
});
</script>
<!-- #third_step -->
<div >
	<div class="form">
		<table cellpadding="2" cellspacing="1" class="table" style="width:95%;">
			<tr>
				<td class="td_title">Install Database</td>
			</tr>
			<tr>
				<td class="td_content">
<textarea id="typewriter" style=" height:250px;width:100%; font-family:arial; font-size:10px;" readonly>
<?php if (file_exists("../_libs/mysql.php")) { ?>
/*
* Copyright by in-Zane.de || All rights Reserved
*/
SQL Database loadet...
Import log_action ...
Import log_lastsearch ...
Import module_banlist ...
Import module_calendar ...
Import module_creport ...
Import module_donate ...
Import module_events ...
Import module_news ...
Import module_preport ...
Import module_preport_answers ...
Import module_rules ...
Import module_rules_points ...
Import module_shoutbox ...
Import module_votebanners ...
Import website_access_levels ...
Import website_modules ...
Import website_navigation ...
Import website_settings ...
Everything is Installed now! Please wait a second! <?php } else { ?>/*
* Copyright by in-Zane.de || All rights Reserved
*/
SQL Database loadet...
Cant find mysql.php 
Cannot import tables
Installation failed! 
<?php } ?></textarea>      
				</td>
			</tr>
		</table>  
		         
	</div>      <!-- clearfix --><div class="clear"></div><!-- /clearfix -->
</div>      <!-- clearfix --><div class="clear"></div><!-- /clearfix -->